<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
 	<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body>
<div class="container-fluid" id="main-container">
    <div id="page-content" class="clearfix">
        <div class="row-fluid">
            <div class="row-fluid">
                <!-- 检索  -->
                <div class="ibox-title" style="border-color: white;">
                    <div class="row">
                    	<div class="col-sm-12">
							<div class="form-group form-inline">
								<span>出&nbsp;差&nbsp;人&nbsp;名&nbsp;称：</span>
								<input id="personName" name="personName" type="text" placeholder="请输入出差人名称" class="input-sm form-control" style="width: 15%;">
								<span>&nbsp;&nbsp;&nbsp;&nbsp;起止时间：</span>
								<input id="startDate" type="text" placeholder="请输入开始时间" class="input-sm form-control form_datetime" readonly="readonly">—
								<input id="endDate" type="text" placeholder="请输入结束时间" class="input-sm form-control form_datetime" readonly="readonly">        
								<span>&nbsp;&nbsp;&nbsp;&nbsp;公司是否预订酒店：</span>
                                <select class="form-control"  id="reservation" name="reservation" >
									<option value="">==请选择==</option>
									<option value="1">是</option>
									<option value="2">否</option>
							    </select>
							</div>
						</div>
						<div class="col-sm-12">
							<div class="form-group form-inline">
								<span>交通工具名称：</span>
								<input id="vehicleName" name="vehicleName" type="text" placeholder="请输入交通工具名称" class="input-sm form-control" style="width: 15%;">
                                <span>&nbsp;&nbsp;&nbsp;&nbsp;出差地点：</span>
								<input id="destination" name="destination" type="text" placeholder="请输入出差地点" class="input-sm form-control" style="width: 15%;">
                                 	<a id="find_btn" type="button" class="btn btn-sm btn-primary"> 搜索</a> 
                                    <a id="reset_btn" type="button" class="btn btn-sm btn-warning"> 重置</a>
                                <s:hasPermission name="evection:add">
	                                <a class="btn btn-sm btn-success" style="margin-left: 20px;" onclick="showadd();"> 添加</a>
	                            </s:hasPermission>
							</div>
						</div>
                    </div>
                </div>
                <!-- biaogebigin -->
                <div class="ibox-content" style=" padding-left: 0px; margin-top: 10px;">
                    <div class="jqGrid_wrapper">
                        <table id="table_list"></table>
                        <div id="pager_list"></div>
                    </div>
                </div>
                <!-- tableover -->
            </div>
            <!-- PAGE CONTENT ENDS HERE -->

        </div>
        <!--/row-->
    </div>
    <!--/#page-content-->
</div>
<!--/.fluid-container#main-container-->
<script type="text/javascript">
	$(".form_datetime").datetimepicker({
		minView: "month",//设置只显示到月份
		format : "yyyy-mm-dd",//日期格式
		autoclose:true,//选中关闭
		todayBtn: true,//今日按钮
		language:  'zh-CN',
	});
    $(top.hangge());
    	var types = "oa_evection_vehicle";
        $.jgrid.defaults.styleUI = "Bootstrap";
        $("#table_list").jqGrid({
            url: '<%=contextPath%>/evection/listData',
            datatype: "json",
            postData: {'type':types}, //发送数据
            autowidth: true,
            rownumbers: true,
            shrinkToFit: true,
            sortname: 'createDate',
            sortorder: "desc",
            mtype: "post",
            rowNum: 10,
            rowList: [10, 20, 30],
            colNames: [
			"id",
			"出差人ID",
			"出差人名称",
			"出差地点",
			"外出时间",
			"返岗时间",
			"出差时长",
			"交通工具ID",
			"交通工具名称",
			"费用预算详情",
			"公司是否预订酒店",
			"备注",
	         "操作"],
            colModel: [
			{name: "id",index: "id",hidden: true}, 
			{name:"person",index:"person",width:100,hidden: true},
			{name:"personName",index:"personName",width:100},
			{name:"destination",index:"destination",width:100},
			{name:"outOfTime",index:"outOfTime",width:100,editable:false,formatter:"date",formatoptions: {srcformat:'Y-m-d H:i:s',newformat:'Y-m-d H:i:s'}},
			{name:"returnTime",index:"returnTime",width:100,editable:false,formatter:"date",formatoptions: {srcformat:'Y-m-d H:i:s',newformat:'Y-m-d H:i:s'}},
			{name:"difftime",index:"difftime",width:100},
			{name:"vehicleId",index:"vehicleId",width:100,hidden: true},
			{name:"vehicleName",index:"vehicleName",width:100},
			{name:"budget",index:"budget",
				formatter: function (cellvalue, options, row) {
					if (cellvalue==null || cellvalue=="" || cellvalue=="undefined") {
						return "暂无";
					} else {
						return cellvalue;
					}
				},width:100
			},
			{name:"reservation",index:"reservation",
				formatter: function (cellvalue, options, row) {
					if (cellvalue==1) {
						return "<span class='btn-sm btn-info'>是</span>";
					} else if(cellvalue==2) {
						return "<span class='btn-sm btn-danger'>否</span>";
					} 
				},width:100
			},//【1：是，2：否】
			{name:"remark",index:"remark",
				formatter: function (cellvalue, options, row) {
					if (cellvalue==null || cellvalue=="" || cellvalue=="undefined") {
						return "暂无";
					} else {
						return cellvalue;
					}
				},width:100
			},
	        {
                formatter: function (cellvalue, options, row) {
                    return " <s:hasPermission name="evection:detail"><a class='btn btn-sm btn-info' title='查看' onclick='showeye(&quot;" + row.id + "&quot;)'><i class='icon-eye-open'></i></a></s:hasPermission> " 
                         + " <s:hasPermission name="evection:edit"><a class='btn btn-sm btn-warning' title='修改' onclick='showedit(&quot;" + row.id + "&quot;)'><i class='icon-edit'></i></a></s:hasPermission> "
                         + " <s:hasPermission name="evection:delete"><a class='btn btn-sm btn-danger' title='删除' onclick='del(&quot;" + row.id + "&quot;)'><i class='icon-trash'></i></a></s:hasPermission> ";
                },
                width: 180
            }],
            height: $(window).height() - 170,
            pager: "#pager_list",
            multiselect: true,//多选按钮
            //multiboxonly: true,
            viewrecords: true,
            hidegrid: false
        });
        //表格自适应高宽
        $(window).bind("resize", function () {
            var b = $(".jqGrid_wrapper").width();
            $("#table_list").setGridWidth(b);
            $("#table_list").setGridHeight($(window).height() - 170);
        })
        $("#table_list").navGrid('#pager_list', {edit: false, add: false, del: false, search: false})
        /* 判断是否有添加权限 */
        //检索
        $("#find_btn").click(function () {
        	//出差人名称
            var personName = $("#personName").val();
        	//交通工具名称
            var vehicleName = $("#vehicleName").val();
            //出差地点
            var destination = $("#destination").val();
            //公司是否预订酒店【1：是，2：否】
            var reservation = $("#reservation").val();
            //开始时间
            var startDate = $('#startDate').val();
            if(startDate!=""){
            	startDate=startDate+" 00:00:00"
            }
            //结束时间
            var endDate = $('#endDate').val();
            if(endDate!=""){
            	endDate=endDate+" 23:59:59";
            }
            $("#table_list").jqGrid('setGridParam', {
                postData: {
                	'name': personName,
                	'vehicleName': vehicleName,
                	'destination': destination,
                	'reservation': reservation,
                	'endDate':endDate,
                	'startDate':startDate
                }, //发送数据
                page: 1
            }).trigger("reloadGrid"); //重新载入
        });
        //重置
        $("#reset_btn").click(function(){ 
        	location.reload();
		});
    //查看
    function showeye(id) {
        openyem("查看出差登记", "<%=contextPath%>/evection/detailView?id=" + id, 550, 500);
    }
    //删除
    function del(id) {
        swalopen(id, "<%=contextPath%>/evection/delete");
    };
    //修改
    function showedit(id) {
        openyem("修改出差登记", "<%=contextPath%>/evection/editView?id=" + id, 550, 500);
    }
    //添加
    function showadd(id) {
        openyem("添加出差登记", "<%=contextPath%>/evection/addView", 550, 500);
    }
</script>
</body>
</html>

